package processor

import (
	"gitee.com/fenquen/go_aop/utils"
	"reflect"
)

func Before(variadic bool, params ...any) {

}

func Around(function any, variadic bool, params ...any) []any {
	functionValue := reflect.ValueOf(function)

	paramValues := utils.ConvertSlice(params, func(param any) reflect.Value {
		return reflect.ValueOf(param)
	})

	var returnedValues []reflect.Value
	if variadic {
		returnedValues = functionValue.CallSlice(paramValues)
	} else {
		returnedValues = functionValue.Call(paramValues)
	}

	return utils.ConvertSlice(returnedValues, func(returnedValue reflect.Value) any {
		return returnedValue.Interface()
	})
}

func After(returnedValues... any) {

}
